<?php
namespace Home\Controller;
use Think\Controller;
class DicController extends CommonController {
    public function index()
    {
        $dics = F('dic','',C('ITEM_PATH'));
        $this->assign('dics',$dics);
        $this->display();
    }

    public function insert($label='',$field='')
    {
        $dics = F('dic','',C('ITEM_PATH'));
        $k['ipttype'] = 'input';
        $k['format'] = 'text';
        $k['isshow'] = 1;
        $k['field'] = $field;
        $k['label'] = $label;
        $dics[$field] = $k;
        F('dic',$dics,C('ITEM_PATH'));
        $this->success('新增成功');
    }

    public function updateFrom($tb = '',$name ='',$pk ='',$value = '',$scene = 'Common')
    {
        $info = F($tb,'',C('ITEM_PATH'));
        if (!$info) $this->error('修改失败');
        $value = str_replace("：", ":", $value);
        $info[$pk][$name] = $value;
        F($tb,$info,C('ITEM_PATH'));
        $this->success('修改成功');
    }

    public function delete($tb = '',$field='')
    {
        $info = F($tb,'',C('ITEM_PATH'));
        if (!$info) $this->error('修改失败');
        unset($info[$field]);
        F($tb,$info,C('ITEM_PATH'));
        $this->success('修改成功');
    }
}